package com.example.gslih.myapplication.file.impl;

import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;

import com.example.gslih.myapplication.R;
import com.example.gslih.myapplication.log.TtLogUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static android.os.Environment.MEDIA_MOUNTED;
import static android.os.Environment.getDataDirectory;
import static android.os.Environment.getDownloadCacheDirectory;
import static android.os.Environment.getExternalStorageDirectory;
import static android.os.Environment.getExternalStoragePublicDirectory;
import static android.os.Environment.getRootDirectory;

/**
 * create by gene 2018/12/21  16:49
 */
public class FilePahActivity extends AppCompatActivity {
    @BindView(R.id.button)
    Button button;
    @BindView(R.id.button2)
    Button button2;
    @BindView(R.id.button3)
    Button button3;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_filepath);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.button)
    public void onButtonClicked() {
        //当前包名  com.example.gslih.myapplication
        TtLogUtil.d(getPackageName());
        //当前类名  a.FilePathActivity
        TtLogUtil.d(getLocalClassName());
        //内部File路径  /data/user/0/com.example.gslih.myapplication/files
        TtLogUtil.d(getFilesDir().toString());
        //内部Cache路径  /data/user/0/com.example.gslih.myapplication/cache
        TtLogUtil.d(getCacheDir().toString());
        //外部Cache路径  /storage/emulated/0/Android/data/com.example.gslih.myapplication/cache
        TtLogUtil.d(getExternalCacheDir().toString());
        //外部File路径  /storage/emulated/0/Android/data/com.example.gslih.myapplication/files
        TtLogUtil.d(getExternalFilesDir("").toString());
        //判断外部存储是否可用
        TtLogUtil.d(MEDIA_MOUNTED.equals(Environment.getExternalStorageState())+"");
        //内部存储根目录  /data
        TtLogUtil.d(getDataDirectory().toString());
        //外部存储根目录  /storage/emulated/0
        TtLogUtil.d(getExternalStorageDirectory().toString());
        //公路径  /storage/emulated/0
        TtLogUtil.d(getExternalStoragePublicDirectory("").toString());
        //下载路径，实质任然是内部存储  /cache
        TtLogUtil.d(getDownloadCacheDirectory().toString());
        //系统路径，实质任然是内部存储  /system
        TtLogUtil.d(getRootDirectory().toString());
    }

    @OnClick(R.id.button2)
    public void onButton2Clicked() {
    }

    @OnClick(R.id.button3)
    public void onButton3Clicked() {
    }
}
